/**
 * Copyright (c) 2018 慢性病开源 All rights reserved.
 *
 * https://www.chronic.io
 *
 * 版权所有，侵权必究！
 */

package io.chronic;

import cn.hutool.system.SystemUtil;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

/**
 * chronic-generator
 *
 * @author Mark sunlightcs@gmail.com
 */

@SpringBootApplication
public class GeneratorApplication {

	public static void main(String[] args) {
		ConfigurableApplicationContext application = SpringApplication.run(GeneratorApplication.class, args);
		Environment env = application.getEnvironment();
		String contextPath = env.getProperty("server.servlet.context-path");
		String ip = SystemUtil.getHostInfo().getAddress();
		String port = env.getProperty("server.port");
		StringBuilder startLog = new StringBuilder();
		startLog.append("\n----------------------------------------------------------\n\t")
				.append("Port: %s\n\t")
				.append("Pid: %s\n\t")
				.append("Address: %s\n\t")
				.append("\n----------------------------------------------------------\n\t");
		System.out.printf(startLog.toString(), port, SystemUtil.getCurrentPID(),
				String.format("http://%s:%s%s", ip, port,contextPath)).println();
	}
}
